//
//  VisitorView.swift
//  myWeibo
//
//  Created by 章发晨 on 2017/3/8.
//  Copyright © 2017年 章发晨. All rights reserved.
//

import UIKit

class VisitorView: UIView {

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    func setupUI(){
        addSubview(imageView)
        imageView.translatesAutoresizingMaskIntoConstraints = false
        /**
         参数1：要添加约束的对象
         参数2：要添加哪个约束
         参数3：约束与约束之前的关系 一般都用 equal
         参数4：参照约束的对象
         参数5：要约束参照对象的那个约束
         参数6：乘积
         参数7：偏移量
         */
        addConstraint(NSLayoutConstraint(item: imageView, attribute: .Top, relatedBy: .Equal, toItem: self, attribute: .Top, multiplier: 1, constant: 0))
        
        addConstraint(NSLayoutConstraint(item: imageView, attribute: .Left, relatedBy: .Equal, toItem: self, attribute: .Left, multiplier: 1, constant: 0))

        addConstraint(NSLayoutConstraint(item: imageView, attribute: .Right, relatedBy: .Equal, toItem: self, attribute: .Right, multiplier: 1, constant: 0))

        addConstraint(NSLayoutConstraint(item: imageView, attribute: .Bottom, relatedBy: .Equal, toItem: self, attribute: .Bottom, multiplier: 1, constant: 0))


    }
    
    
    private lazy var imageView:UIImageView = {
        
        let imageView = UIImageView(image: UIImage(named: "tu"))
        return imageView
        
    }()
    
    
}
